package com.glls.java2217.controller;

import com.glls.java2217.common.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @date 2023-01-04
 * @desc
 */
@RequestMapping("/test")
@RestController   // @Controller + @ResponseBody
public class TestController {

    @RequestMapping("/test1")
    public R test(){

        return R.ok();
    }


    //登录
    @RequestMapping("/login")
    public R login(String name,String password){
        System.out.println(name);
        System.out.println(password);
        return R.ok();
    }

    //restful   风格的请求
    //把参数写在请求路径上面 http://localhost:8080/test/login2/zs/123
    // 请求参数zs 匹配 下面的 {name}     123 匹配下面的{password}
    // 请求参数上 使用 @PathVariable
    @RequestMapping("/login2/{name}/{password}")
    public R login2(@PathVariable("name") String name,@PathVariable("password") String password){
        System.out.println(name);
        System.out.println(password);
        return R.ok();
    }


}
